﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;
using System.Text;
using System.IO;
using System.Reflection;

namespace mLabControls
{
    public class Labela
    {
        private string _id;
        public string Id { get { return _id; } set { _id = value; } }

        private string _text;
        public string Text { get { return _text; } set { _text = value; } }
    }

    public static class TranslateLabela
    {
        private static List<Labela> labele;

        public static void UcitajFile()
        {
            labele = new List<Labela>();

            string filePath = @"..\Labele.txt";
            string line;

            if (File.Exists(filePath))
            {
                StreamReader file = null;
                try
                {
                    file = new StreamReader(filePath);
                    while ((line = file.ReadLine()) != null)
                    {
                        string[] words = line.Split(';');
                        Labela lbl = new Labela();
                        lbl.Id = words[0];
                        lbl.Text = words[1];
                        labele.Add(lbl);
                    }
                }
                finally
                {
                    if (file != null)
                        file.Close();
                }
            }
        }

        public static string Prevedi(string id)
        {
            if(labele == null)
            {
                UcitajFile();
            } 

            return (from line in labele where line.Id == id select line).SingleOrDefault().Text.ToString();
         }
    }
}
